<!DOCTYPE html>
<html lang="zh-CN">
<head><meta name="generator" content="Hexo 3.9.0">
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  
  <title itemprop="name">Codeforces Round #622 (Div. 2) | SQRock</title>
  
    <link rel="shortcut icon" href="/images/头像.jpg">
  
  <meta http-equiv="x-dns-prefetch-control" content="on">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+SerifMerriweather|Merriweather+Sans|Source+Code+Pro|Ubuntu:400,700|Noto+Serif+SC" media="all">
  <link rel="dns-prefetch" href="//cdn.jsdelivr.net">
  <link rel="stylesheet" id="saukra_css-css" href="/css/style.css" type="text/css" media="all">
  <link rel="stylesheet" href="/css/lib.min.css" media="all">
  <link rel="stylesheet" href="/css/font.css" media="all">
  <link rel="stylesheet" href="/css/insight.css" media="all">
  <link rel="stylesheet" href="/css/jquery.fancybox.min.css" media="all">
  <link rel="stylesheet" href="/css/zoom.css" media="all">
  <link rel="stylesheet" type="text/css" href="/css/sharejs.css">
<!--   <link rel="stylesheet" id="saukra_css-css" href="https://2heng.xin/wp-content/cache/autoptimize/css/autoptimize_ad42a61f4c7d4bdd9f91afcff6b5dda5.css
" type="text/css" media="all"> -->
  <script>
  /*Initial Variables*/
  var mashiro_option = new Object();
  var mashiro_global = new Object();
  mashiro_option.NProgressON = true;
  /* 
   * 邮箱信息之类的东西可以填在这里，这些js变量基本都作用于sakura-app.js
   * 这样的设置仅是为了方便在基于PHP开发的主题中设置js变量，既然移植到了Node上，我想或许可以精简这一逻辑吧
   */
  mashiro_option.email_domain = "";
  mashiro_option.email_name = "";
  mashiro_option.cookie_version_control = "";
  mashiro_option.qzone_autocomplete = false;
  mashiro_option.site_name = "SQ_Rock";
  mashiro_option.author_name = "";
  mashiro_option.site_url = "https://www.shi747826.com";
  mashiro_option.v_appId = "UxYfusXUbSO4XIT105k8RsWo-gzGzoHsz";
  mashiro_option.v_appKey = "Qcqav1HXc6Afma8BAuuFY9LA";
  mashiro_option.mathjax = "[object Object]";
  mashiro_option.qq_api_url = "https://api.mashiro.top/qqinfo/"; 
  mashiro_option.qq_avatar_api_url = "https://api.mashiro.top/qqinfo/";

  // mashiro_option.jsdelivr_css_src = "https://cdn.jsdelivr.net/gh/moezx/cdn@3.4.5/css/lib.min.css";
  // mashiro_option.float_player_on = true;

  /*End of Initial Variables*/
  </script>
  <script type="text/javascript">
  var bg = "https://cdn.jsdelivr.net/gh/shi747826/cdn@1.3/cover/1.jpg,https://cdn.jsdelivr.net/gh/shi747826/cdn@1.3/cover/2.jpg,https://cdn.jsdelivr.net/gh/shi747826/cdn@1.3/cover/3.jpg,https://cdn.jsdelivr.net/gh/shi747826/cdn@1.3/cover/4.jpg,https://cdn.jsdelivr.net/gh/shi747826/cdn@1.3/cover/5.jpg".split(",");
  var bgindex = Math.floor(Math.random()*bg.length);
  if (!!window.ActiveXObject || "ActiveXObject" in window) { //is IE?
    alert('朋友，IE浏览器未适配哦~');
  }
  </script>
  <style type="text/css">
  .hljs-ln{border-collapse:collapse}.hljs-ln td{padding:0}.hljs-ln-n:before{content:attr(data-line-number)}
  </style>
  <style type="text/css">.site-top .lower nav{display:block !important;}.author-profile i,.post-like a,.post-share .show-share,.sub-text,.we-info a,span.sitename,.post-more i:hover,#pagination a:hover,.post-content a:hover,.float-content i:hover{color:#FE9600}.feature i,.download,.navigator i:hover,.links ul li:before,.ar-time i,span.ar-circle,.object,.comment .comment-reply-link,.siren-checkbox-radio:checked + .siren-checkbox-radioInput:after{background:#FE9600}::-webkit-scrollbar-thumb{background:#FE9600}.download,.navigator i:hover,.link-title,.links ul li:hover,#pagination a:hover,.comment-respond input[type='submit']:hover{border-color:#FE9600}.entry-content a:hover,.site-info a:hover,.comment h4 a,#comments-navi a.prev,#comments-navi a.next,.comment h4 a:hover,.site-top ul li a:hover,.entry-title a:hover,#archives-temp h3,span.page-numbers.current,.sorry li a:hover,.site-title a:hover,i.iconfont.js-toggle-search.iconsearch:hover,.comment-respond input[type='submit']:hover{color:#FE9600}.comments .comments-main{display:block !important;}.comments .comments-hidden{display:none !important;}background-position:center center;background-attachment:inherit;}
  </style><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</head>
</html>
<body class="page-template page-template-user page-template-page-analytics page-template-userpage-analytics-php page page-id-1297 chinese-font serif isWebKit">
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="scrollbar" id="bar">
  </div>
  <a href="#" class="cd-top faa-float animated"></a>
  <section id="main-container">
    <div class="headertop filter-dot">
  <div id="banner_wave_1"></div>
  <div id="banner_wave_2"></div>
  <figure id="centerbg" class="centerbg">
    <div class="focusinfo no-select">
      <div class="header-tou">
        <a href="https://www.shi747826.com">
          <img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/头像.jpg">
        </a>
      </div>
      <div class="header-info">
        <p>Live your life with passion! With some drive!</p>
        <div class="top-social_v2">
          <li id="bg-pre">
            <img class="flipx" src="https://cdn.jsdelivr.net/gh/honjun/cdn@1.6/img/other/next-b.svg">
          </li>
          
            
              
                <li>
                  <a href="http://github.com/shi747826" target="_blank" class="social-github" title="github">
                    <img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/social/github.png">
                  </a>
                </li>
              
            
              
                <li>
                  <a href="https://music.163.com/#/user/home?id=544257352" target="_blank" class="social-github" title="wangyiyun">
                    <img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/social/wangyiyun.png">
                  </a>
                </li>
              
            
              
                <li>
                  <a href="mailto:188250173@qq.com" target="_blank" class="social-github" title="email">
                    <img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/social/email.svg">
                  </a>
                </li>
              
            
              
                <li>
                  <a href="https://wpa.qq.com/msgrd?v=3&amp;uin=188250173&amp;site=qq&amp;menu=yes" target="_blank" class="social-github" title="qq">
                    <img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/social/qq.png">
                  </a>
                </li>
              
            
          
          <li id="bg-next">
            <img src="https://cdn.jsdelivr.net/gh/honjun/cdn@1.6/img/other/next-b.svg">
          </li>
        </div>
      </div>
    </div>
  </figure>
  <div id="video-container" style="">
    <video style="object-fit: fill" id="bgvideo" class="video" video-name="" src="" width="auto" preload="auto">
    </video>
    <div id="video-btn" class="loadvideo videolive">
    </div>
    <div id="video-add">
    </div>
    <div class="video-stu">
    </div>
  </div>
  <div class="headertop-down faa-float animated" onclick="headertop_down()">
    <span>
      <i class="fa fa-chevron-down" aria-hidden="true">
      </i>
    </span>
  </div>
</div>
    <div id="page" class="site wrapper">
      <header class="site-header no-select gizle sabit" role="banner">
  <div class="site-top">
    <div class="site-branding">
      <span class="site-title">
        <span class="logolink moe-mashiro">
          <a href="/">
            <span class="sakurasono">SQ_Rock</span>
            <span class="shironeko"></span>
          </a>
        </span>
      </span>
    </div>
    <div class="searchbox search-form-submit">
      <i class="iconfont js-toggle-search iconsearch icon-search">
      </i>
    </div>
    <div id="show-nav" class="showNav mobile-fit">
      <div class="line line1">
      </div>
      <div class="line line2">
      </div>
      <div class="line line3">
      </div>
    </div>
    <div class="lower-cantiner">
      <div class="lower">
        <nav class="mobile-fit-control hide">
          <ul id="menu-new" class="menu">
            
              <li>
                <a href="/">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-fort-awesome faa-shake" aria-hidden="true"></i>
                    首页
                  </span>
                </a>
                
              </li>
            
              <li>
                <a href="/archives">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-archive faa-shake" aria-hidden="true"></i>
                    归档
                  </span>
                </a>
                
                  <ul class="sub-menu">
                    
                      <li>
                        <a href="/categories/算法/">
                          <i class="fa fa-code" aria-hidden="true"></i>
                          算法
                        </a>
                      </li>
                    
                      <li>
                        <a href="/categories/生活/">
                          <i class="fa fa-file-text-o" aria-hidden="true"></i>
                          生活
                        </a>
                      </li>
                    
                      <li>
                        <a href="/categories/笔记/">
                          <i class="fa fa-book" aria-hidden="true"></i>
                          笔记
                        </a>
                      </li>
                    
                      <li>
                        <a href="/categories/资源/">
                          <i class="fa fa-cloud-download" aria-hidden="true"></i>
                          资源
                        </a>
                      </li>
                    
                  </ul>
                
              </li>
            
              <li>
                <a href="/music/">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-headphones" aria-hidden="true"></i>
                    歌单
                  </span>
                </a>
                
              </li>
            
              <li>
                <a href="/comment/">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-pencil-square-o faa-tada" aria-hidden="true"></i>
                    留言板
                  </span>
                </a>
                
              </li>
            
              <li>
                <a href="/links/">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-link faa-shake" aria-hidden="true"></i>
                    友人帐
                  </span>
                </a>
                
              </li>
            
              <li>
                <a href="/about/">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-meetup" aria-hidden="true"></i>
                    关于
                  </span>
                </a>
                
              </li>
            
              <li>
                <a href="/lab/">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-cogs" aria-hidden="true"></i>
                    实验室
                  </span>
                </a>
                
              </li>
            
              <li>
                <a href="/atom.xml">
                  <span class="faa-parent animated-hover">
                    <i class="fa  fa-rss faa-pulse" aria-hidden="true"></i>
                    RSS
                  </span>
                </a>
                
              </li>
            
          </ul>
        </nav>
      </div>
    </div>
  </div>
</header>

      <link rel="stylesheet" type="text/css" href="/css/sharejs.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.css">
<div class="pattern-center-blank"></div>

  <div class="pattern-center single-center">
    <!-- 有配图默认渲染第一张 -->
    <div class="pattern-attachment-img lazyload" style="background-image: url(https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/img/imgIMG_3440.GIF);" src="https://cdn.jsdelivr.net/gh/honjun/cdn@1.6/img/loader/orange.progress-bar-stripe-loader.svg" data-src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/img/imgIMG_3440.GIF">
    </div>
    <header class="pattern-header single-header">
      <h1 class="entry-title">
      Codeforces Round #622 (Div. 2)</h1>
      <p class="entry-census">
        <span>
          <a href="https://www.shi747826.com">
            <img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.1/images/头像.jpg">
          </a>
        </span>
        <span>
          <a href="https://www.shi747826.com">SQRock</a>
        </span>
        <span class="bull">
        ·</span>
        2020-2-23<span class="bull">
        ·</span>
      <span id="busuanzi_value_page_pv"></span>次阅读</p>
    </header>
  </div>

<div id="content" class="site-content">
  <div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">
      <article id="post-1" class="post-1 post type-post status-publish format-standard has-post-thumbnail hentry category-uncategorized">
        <div class="toc"></div>
        <!--<div class="toc-entry-content"><!-- 套嵌目录使用（主要为了支援评论）-->
        
        <div class="entry-content">
          <h1 id="A-Fast-Food-Restaurant"><a href="#A-Fast-Food-Restaurant" class="headerlink" title="A. Fast Food Restaurant"></a><a href="https://codeforces.ml/contest/1313/problem/A" target="_blank" rel="noopener">A. Fast Food Restaurant</a></h1><p>Tired of boring office work, Denis decided to open a fast food restaurant.</p>
<p>On the first day he made <strong>a</strong> portions of dumplings, <strong>b</strong> portions of cranberry juice and <strong>c</strong> pancakes with condensed milk.</p>
<p>The peculiarity of Denis’s restaurant is the procedure of ordering food. For each visitor Denis himself chooses a set of dishes that this visitor will receive. When doing so, Denis is guided by the following rules:</p>
<ul>
<li>every visitor should receive at least one dish (dumplings, cranberry juice, pancakes with condensed milk are all considered to be dishes);</li>
<li>each visitor should receive no more than one portion of dumplings, no more than one portion of cranberry juice and no more than one pancake with condensed milk;</li>
<li>all visitors should receive different sets of dishes.</li>
</ul>
<p>What is the maximum number of visitors Denis can feed?</p>
<h2 id="Input"><a href="#Input" class="headerlink" title="Input"></a><strong>Input</strong></h2><p>The first line contains an integer <strong>t</strong> (1 ≤ t ≤ 500) — the number of test cases to solve.</p>
<p>Each of the remaining <strong>t</strong> lines contains integers <strong>a</strong>, <strong>b</strong> and <strong>c</strong> (0 ≤ a,b,c ≤ 10) — the number of portions of dumplings, the number of portions of cranberry juice and the number of condensed milk pancakes Denis made.</p>
<h2 id="Output"><a href="#Output" class="headerlink" title="Output"></a><strong>Output</strong></h2><p>For each test case print a single integer — the maximum number of visitors Denis can feed.</p>
<h2 id="Example"><a href="#Example" class="headerlink" title="Example"></a><strong>Example</strong></h2><h3 id="input"><a href="#input" class="headerlink" title="input"></a><strong>input</strong></h3><pre><code>7
1 2 1
0 0 0
9 1 7
2 2 3
2 3 2
3 2 2
4 4 4
</code></pre><h3 id="output"><a href="#output" class="headerlink" title="output"></a><strong>output</strong></h3><pre><code>3
0
4
5
5
5
7
</code></pre><h2 id="Note"><a href="#Note" class="headerlink" title="Note"></a><strong>Note</strong></h2><p>In the first test case of the example, Denis can feed the first visitor with dumplings, give the second a portion of cranberry juice, and give the third visitor a portion of cranberry juice and a pancake with a condensed milk.</p>
<p>In the second test case of the example, the restaurant Denis is not very promising: he can serve no customers.</p>
<p>In the third test case of the example, Denise can serve four visitors. The first guest will receive a full lunch of dumplings, a portion of cranberry juice and a pancake with condensed milk. The second visitor will get only dumplings. The third guest will receive a pancake with condensed milk, and the fourth guest will receive a pancake and a portion of dumplings. Please note that Denis hasn’t used all of the prepared products, but is unable to serve more visitors.</p>
<h2 id="Problem-solving"><a href="#Problem-solving" class="headerlink" title="Problem solving:"></a>Problem solving:</h2><p>题意就是有三种不同的食物，给出三种食物的数量，问有多少种食物搭配的方案（可以用1种、2种或3种食物进行搭配，只要没出现过就可以）。</p>
<p>很明显先从只选1种食物开始，如果当前数量大于1，方案数就加一。</p>
<p>然后从2种食物开始搭配，优先贪心选择剩余数量最多的两种，然后再<del>乱搞</del>（两两选择）。</p>
<p>最后如果3种食物数量都大于1，就可以再加一种方案（选择三种食物）。</p>
<pre><code class="lang-c++">#include&lt;bits/stdc++.h&gt;
using namespace std;
const ll N = 1e5+7;
int main()
{
    int t;
    cin&gt;&gt;t;
    while(t--)
    {
        int a,b,c;
        cin&gt;&gt;a&gt;&gt;b&gt;&gt;c;
        int ans=0;
        if(a&gt;0) a--,ans++;
        if(b&gt;0) b--,ans++;
        if(c&gt;0) c--,ans++;

        int k[3];
        k[0]=a;
        k[1]=b;
        k[2]=c;
        sort(k,k+3);

        if(k[2]&gt;0 &amp;&amp; k[1]&gt;0) k[2]--,k[1]--,ans++;//先选择最多的两个
        //下面是乱搞的
        if(k[0]&gt;0 &amp;&amp; k[2]&gt;0) k[0]--,k[2]--,ans++;
        if(k[1]&gt;0 &amp;&amp; k[0]&gt;0) k[1]--,k[0]--,ans++;

        if(k[1]&gt;0 &amp;&amp; k[0]&gt;0 &amp;&amp; k[2]&gt;0) ans++;
        cout&lt;&lt;ans&lt;&lt;endl;
     } 

    return 0;
}
</code></pre>
<h1 id="B-Different-Rules"><a href="#B-Different-Rules" class="headerlink" title="B. Different Rules"></a><a href="https://codeforces.ml/contest/1313/problem/B" target="_blank" rel="noopener">B. Different Rules</a></h1><p>Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious Olympiad. There going to be <strong>n</strong> participants, one of whom is Nikolay. Like any good Olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.</p>
<p>Suppose in the first round participant A took <em>x</em>-th place and in the second round — <em>y</em>-th place. Then the total score of the participant A is sum <strong>x</strong> + <strong>y</strong>. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every <em>i</em> from <em>1</em> to <em>n</em> <strong>exactly one</strong> participant took <em>i</em>-th place in first round and <strong>exactly one</strong> participant took <em>i</em>-th place in second round.</p>
<p>Right after the end of the Olympiad, Nikolay was informed that he got <em>x</em>-th place in first round and <em>y</em>-th place in the second round. Nikolay doesn’t know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.</p>
<h2 id="Input-1"><a href="#Input-1" class="headerlink" title="Input"></a><strong>Input</strong></h2><p>The first line contains an integer <strong>t</strong> (1 ≤ t ≤ 100) — the number of test cases to solve.</p>
<p>Each of the following <strong>t</strong> lines contains integers <strong>n</strong>, <strong>x</strong>, <strong>y</strong> (1 ≤ n ≤ 10<sup>9</sup>, 1 ≤ x, y ≤ n) — the number of participants in the Olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.</p>
<h2 id="Output-1"><a href="#Output-1" class="headerlink" title="Output"></a><strong>Output</strong></h2><p>Print two integers — the minimum and maximum possible overall place Nikolay could take.</p>
<h2 id="Examples"><a href="#Examples" class="headerlink" title="Examples"></a><strong>Examples</strong></h2><h3 id="input-1"><a href="#input-1" class="headerlink" title="input"></a><strong>input</strong></h3><pre><code>1
5 1 3
</code></pre><h3 id="output-1"><a href="#output-1" class="headerlink" title="output"></a><strong>output</strong></h3><pre><code>1 3
</code></pre><h3 id="input-2"><a href="#input-2" class="headerlink" title="input"></a><strong>input</strong></h3><pre><code>1
6 3 4
</code></pre><h3 id="output-2"><a href="#output-2" class="headerlink" title="output"></a><strong>output</strong></h3><pre><code>2 6
</code></pre><h2 id="Problem-solving-1"><a href="#Problem-solving-1" class="headerlink" title="Problem solving:"></a>Problem solving:</h2><p>题意是说一共有n个人，有两轮比赛，你第一轮得了第a名。第二轮得了第b名。最后的总名次是按照这两次比赛和名次和来判断的，两轮的名次和越少总名次越高，问已知n,a,b的情况下，最好、最坏能得多少名。</p>
<p>注意两轮比赛中没有两人名次相同的情况，总名次会有相同的情况，例如5个人名次和分别是 4，4，4，8，10，那么这五个人的总名次就是3, 3, 3, 4, 5。</p>
<p>最坏情况就是总名次在你<del>前面</del>的人两轮的名次和都和你相同，这样最多会有a+b-1人（包括自己），而最多只有n人所以最坏情况就是min(n,a+b-1);</p>
<p>至于最好情况，<del>感觉</del>（乱搞）出来的</p>
<pre><code class="lang-c++">#include&lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int t;
    cin&gt;&gt;t;
    while(t--)
    {
        ll n,x,y;
        cin&gt;&gt;n&gt;&gt;x&gt;&gt;y;
        ll sum = x+y;
        //最好
        if(sum&lt;n) cout&lt;&lt;1&lt;&lt;&quot; &quot;;
        else cout&lt;&lt;min(n,sum-n+1)&lt;&lt;&quot; &quot;;
        //最坏
        cout&lt;&lt;min(n,sum-1)&lt;&lt;endl; 
    }    
    return 0;
}
</code></pre>
<h1 id="C1-Skyscrapers-easy-version"><a href="#C1-Skyscrapers-easy-version" class="headerlink" title="C1. Skyscrapers (easy version)"></a><a href="https://codeforces.ml/contest/1313/problem/C1" target="_blank" rel="noopener">C1. Skyscrapers (easy version)</a></h1><p><em>This is an easier version of the problem. In this version n ≤ 1000</em></p>
<p>The outskirts of the capital are being actively built up in Berland. The company “Kernel Panic” manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought n plots along the highway and is preparing to build n skyscrapers, one skyscraper per plot.</p>
<p>Architects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.</p>
<p>Formally, let’s number the plots from 1 to n. Then if the skyscraper on the <strong>i</strong>-th plot has a<sub><em>i</em></sub> floors, it must hold that a<sub><em>i</em></sub> is at most m<sub><em>i</em></sub> (1 ≤ a<sub><em>i</em></sub> ≤ m<sub><em>i</em></sub>). Also there mustn’t be integers <strong>j</strong> and <strong>k</strong> such that j &lt; i &lt; k  and a<sub><em>j</em></sub> &gt; a<sub><em>i</em></sub> &lt; a<sub><em>k</em></sub> . Plots <strong>j</strong> and <strong>k</strong> are <strong>not</strong> required to be adjacent to <strong>i</strong>.</p>
<p>The company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.</p>
<h2 id="Input-2"><a href="#Input-2" class="headerlink" title="Input"></a><strong>Input</strong></h2><p>The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of plots.</p>
<p>The second line contains the integers m<sub>1</sub>,m<sub>2</sub>,…,m<sub>n</sub> (1 ≤ m<sub>i </sub>≤ 10<sup>9</sup>) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.</p>
<h2 id="Output-2"><a href="#Output-2" class="headerlink" title="Output"></a><strong>Output</strong></h2><p>Print n integers a<sub>i</sub> — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.</p>
<p>If there are multiple answers possible, print any of them.</p>
<h2 id="Examples-1"><a href="#Examples-1" class="headerlink" title="Examples"></a><strong>Examples</strong></h2><h3 id="input-3"><a href="#input-3" class="headerlink" title="input"></a><strong>input</strong></h3><pre><code>5
1 2 3 2 1
</code></pre><h3 id="output-3"><a href="#output-3" class="headerlink" title="output"></a><strong>output</strong></h3><pre><code>1 2 3 2 1
</code></pre><h3 id="input-4"><a href="#input-4" class="headerlink" title="input"></a><strong>input</strong></h3><pre><code>3
10 6 8
</code></pre><h3 id="output-4"><a href="#output-4" class="headerlink" title="output"></a><strong>output</strong></h3><pre><code>10 6 6
</code></pre><h2 id="Note-1"><a href="#Note-1" class="headerlink" title="Note"></a><strong>Note</strong></h2><p>In the first example, you can build all skyscrapers with the highest possible height.</p>
<p>In the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer <code>[10,6,6]</code> is optimal. Note that the answer of <code>[6,6,8]</code> also satisfies all restrictions, but is not optimal.</p>
<h2 id="Problem-solving-2"><a href="#Problem-solving-2" class="headerlink" title="Problem solving:"></a>Problem solving:</h2><p>题意是说给你一个序列，让你修改成 j &lt; i &lt; k 情况下没有 a<sub><em>j</em></sub> &gt; a<sub><em>i</em></sub> &lt; a<sub><em>k</em></sub> 的序列，要求修改后的序列和最大。修改时每个数不能超过原来的大小。</p>
<p>这道题因为是easy版本的 ，数据范围比较小，一般情况下就可以用暴力。</p>
<p>我们只需要暴力检查每个点，把当前点当做最大的，依次往两边扫就可以了。</p>
<pre><code class="lang-c++">#include&lt;bits/stdc++.h&gt;
#define fi        first
#define se        second
#define PI        acos(-1)
#define LC(a)     ((a&lt;&lt;1))
#define RC(a)     ((a&lt;&lt;1)+1)
#define MID(a,b)  ((a+b)&gt;&gt;1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair&lt;int,int&gt; PII;
typedef pair&lt;ll,ll&gt;   PLL;
typedef pair&lt;ll,int&gt;  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1&lt;&lt;30);
const ll N = 1e5+7;
int main()
{
    IOS();
    int n;
    cin&gt;&gt;n;
    ll a[1005];
    ll b[1005];
    ll c[1005];
    ll mxi=0;
    for(int i=0; i&lt;n; i++) cin&gt;&gt;a[i];
    ll ans=0;
    ll num;
    for(int mxi=0;mxi&lt;n;mxi++)
    {
        num = a[mxi];
        b[mxi] = a[mxi];
        for(int i=mxi-1; i&gt;=0; i--)
        {
            if(a[i]&gt;b[i+1]) b[i]=b[i+1];
            else b[i] = a[i];
            num+=b[i];
        }
        for(int i=mxi+1; i&lt;n; i++)
        {
            if(a[i]&gt;b[i-1]) b[i]=b[i-1];
            else b[i] = a[i];
            num+=b[i];
        }
        if(ans&lt;num)
        {
            ans=num;
            for(int i=0; i&lt;n; i++) c[i]=b[i];
        }
    }
    for(int i=0; i&lt;n; i++)
        cout&lt;&lt;c[i]&lt;&lt;&quot; &quot;;
    cout&lt;&lt;endl;
    return 0;
}
</code></pre>
<h1 id="C2-Skyscrapers-hard-version"><a href="#C2-Skyscrapers-hard-version" class="headerlink" title="C2. Skyscrapers (hard version)"></a><a href="https://codeforces.ml/contest/1313/problem/C2" target="_blank" rel="noopener">C2. Skyscrapers (hard version)</a></h1><p>这道题和C1是一模一样的，只是n从1000增加到了500 000。</p>
<p>待补！</p>

        </div>
        <!-- .entry-content -->
        <div class="single-reward">
          <div class="reward-open">赏
            <div class="reward-main">
              <ul class="reward-row">
                <li class="alipay-code"><img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/donate/alipay.jpg"></li>
                <li class="wechat-code"><img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/donate/wechatpay.jpg"></li>
              </ul>
            </div>
          </div>
        </div>
        <div style="text-align:center; width: 100%" class="social-share share-mobile" data-disabled="diandian, tencent"></div>
        <footer class="post-footer">
          <div class="post-lincenses"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank" rel="nofollow"><i class="fa fa-creative-commons" aria-hidden="true"></i> 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议</a></div>
          <div class="post-tags">
          </div>
          <div class="post-share">
            <div class="social-share sharehidden share-component"></div>
            <i class="iconfont show-share icon-forward"></i>
          </div>
        </footer><!-- .entry-footer -->
      </article>
      <!-- #post-## -->
      <div class="toc" style="background: none;"></div>
      <section class="post-squares nextprev">
        
          
            <div class="post-nepre half previous">
          
            <a href="/2020/02/24/数据库第一章/" rel="prev">
              <div class="background">
                <img class="lazyload" src="https://cdn.jsdelivr.net/gh/honjun/cdn@1.6/img/loader/orange.progress-bar-stripe-loader.svg" data-src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/img/imgIMG_3441.GIF" style="width: 100%; height: 100%; object-fit: cover; pointer-events: none;" onerror="imgError(this,3)" src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/img/imgIMG_3441.GIF">
              </div>
              <span class="label">
              Previous Post</span>
              <div class="info">
                <h3>
                数据库第一章</h3>
                <hr>
              </div>
            </a>
          </div>
        
        
          
            <div class="post-nepre half next">
          
            <a href="/2020/02/17/数据库作业1/" rel="next">
              <div class="background">
                <img class="lazyload" src="https://cdn.jsdelivr.net/gh/honjun/cdn@1.6/img/loader/orange.progress-bar-stripe-loader.svg" data-src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/img/imgIMG_3438.GIF" style="width: 100%; height: 100%; object-fit: cover; pointer-events: none;" onerror="imgError(this,3)" src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/img/imgIMG_3438.GIF">
              </div>
              <span class="label">
              Next Post</span>
              <div class="info">
                <h3>
                数据库作业1</h3>
                <hr>
              </div>
            </a>
          </div>
        
      </section>
      
<div id="vcomments"></div>
<script>
  window.onload = function(){
      var valine = new Valine();
      valine.init({
        el: '#vcomments',
        appId: "UxYfusXUbSO4XIT105k8RsWo-gzGzoHsz",
        appKey: "Qcqav1HXc6Afma8BAuuFY9LA",
        path: window.location.pathname,
        placeholder: "你是我一生只会遇见一次的惊喜 ..."
      })
  }
</script>

      <section class="author-profile">
        <div class="info" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
          <a href="https://www.shi747826.com" class="profile gravatar"><img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.1/images/头像.jpg" itemprop="image" alt="SQRock" height="70" width="70"></a>
          <div class="meta">
            <span class="title">Author</span>
            <h3 itemprop="name">
            <a href="https://www.shi747826.com" itemprop="url" rel="author">SQRock</a>
            </h3>
          </div>
        </div>
        <hr>
        <p><i class="iconfont icon-write"></i>一个好奇的人</p>
      </section>
    </main><!-- #main -->
  </div><!-- #primary -->
</div>



    </div>    
    <div class="ins-search">
    <div class="ins-search-mask"></div>
    <div class="ins-search-container">
        <div class="ins-input-wrapper">
            <input type="text" class="ins-search-input" placeholder="请输入关键词..."/>
            <span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            // PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
    <!-- <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 SQRock<br>
      powered_by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer> -->
<footer id="colophon" class="site-footer" role="contentinfo">
  <div class="site-info">
    <div class="footertext">
      <div class="img-preload">
        <img src="https://cdn.jsdelivr.net/gh/honjun/cdn@1.6/img/other/wordpress-rotating-ball-o.svg">
        <img src="https://cdn.jsdelivr.net/gh/honjun/cdn@1.6/img/other/disqus-preloader.svg">
      </div>
      <p style="color: #666666;">&copy 2020 SQRock</p>
    </div>
    <div class="footer-device">
    <p style="font-family: 'Ubuntu', sans-serif;">
        <span><a href="http://www.beian.miit.gov.cn/">豫ICP备20003442号</a></br></span>
        <span style="color: #b9b9b9;">Theme <a href="https://github.com/honjun/hexo-theme-sakura" target="_blank" style="color: #b9b9b9;;text-decoration: underline dotted rgba(0, 0, 0, .1);">Sakura</a> <i class="iconfont icon-sakura rotating" style="color: #ffc0cb;display:inline-block"></i> by <a href="https://2heng.xin/" target="_blank" style="color: #b9b9b9;;text-decoration: underline dotted rgba(0, 0, 0, .1);">Mashiro</a>&<a href="https://www.hojun.cn/" target="_blank" style="color: #b9b9b9;;text-decoration: underline dotted rgba(0, 0, 0, .1);">Hojun</a>, Powered by Hexo</a>
        </span>
      </p>
    </div>
  </div><!-- .site-info -->
</footer>



<!-- <script src="/js/tocbot.js"></script> -->
<script type="text/javascript" src="/js/lib.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script type="text/javascript" src="/js/InsightSearch.js"></script>
<script type="text/javascript" src="/js/jquery.fancybox.min.js"></script>
<script type="text/javascript" src="/js/zoom.min.js"></script>
<script type="text/javascript" src="/js/sakura-app.js"></script>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine@1.3.4/dist/Valine.min.js'></script>
<script src="/js/botui.js"></script>
<!-- 不蒜子 网页计数器 -->
<script src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.min.js"></script> -->
<script type="text/javascript">
/* <![CDATA[ */
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
  var Poi = {"pjax":"1","movies":{"url": "https://cdn.jsdelivr.net/gh/honjun/hojun@1.2","name":"Unbroken.mp4","live":"close"},"windowheight":"fixed","codelamp":"close","ajaxurl":"","order":"asc","formpostion":"bottom"};
} else {
  var Poi = {"pjax":"1","movies":{"url": "https://cdn.jsdelivr.net/gh/honjun/hojun@1.2","name":"Unbroken.mp4","live":"open"},"windowheight":"auto","codelamp":"close","ajaxurl":"","order":"asc","formpostion":"bottom"};
}
/* ]]> */

</script>
<script>
$(document).ready(function() {
  if ($(".toc").length > 0 && document.body.clientWidth > 1200) {
    if ($(".pattern-center").length > 0) { //有图的情况
      tocbot.init({
          // Where to render the table of contents.
          tocSelector: '.toc', // 放置目录的容器
          // Where to grab the headings to build the table of contents.
          contentSelector: '.entry-content', // 正文内容所在
          // Which headings to grab inside of the contentSelector element.
          scrollSmooth: true,
          headingSelector: 'h1, h2, h3, h4, h5', // 需要索引的标题级别
          headingsOffset: -400,
          scrollSmoothOffset: -85
      });
    } else {
      tocbot.init({
          // Where to render the table of contents.
          tocSelector: '.toc', // 放置目录的容器
          // Where to grab the headings to build the table of contents.
          contentSelector: '.entry-content', // 正文内容所在
          // Which headings to grab inside of the contentSelector element.
          scrollSmooth: true,
          headingSelector: 'h1, h2, h3, h4, h5', // 需要索引的标题级别
          headingsOffset: -85,
          scrollSmoothOffset: -85
      });
    }
    var offsetTop = $('.toc').offset().top - 95;
    window.onscroll = function() {
      var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
      if (scrollTop >= offsetTop) {
        $('.toc').addClass('toc-fixed');
      } else {
        $('.toc').removeClass('toc-fixed');
      }
    }
  }
});
</script>

    <div class="openNav no-select" style="height: 50px;">
      <div class="iconflat no-select" style="width: 50px; height: 50px;">
        <div class="icon"></div>
      </div>
      <div class="site-branding search-form-submit">
        <i class="iconfont js-toggle-search iconsearch icon-search"></i>
      </div>
    </div>
  </section>
  <div id="mo-nav" class="">
  <div class="m-avatar">
    <img src="https://cdn.jsdelivr.net/gh/shi747826/cdn@1.2/images/头像.jpg">
  </div>
  <p style="text-align: center; color: #333; font-weight: 900; font-family: 'Ubuntu', sans-serif; letter-spacing: 1.5px">SQ_Rock</p>
  <p style="text-align: center; word-spacing: 20px;">
    
      
        <a href="http://github.com/shi747826" class="fa fa-github" target="_blank" style="color: #333; margin-left:20px"></a>
      
        <a href="https://wpa.qq.com/msgrd?v=3&uin=188250173&site=qq&menu=yes" class="fa fa-qq" target="_blank" style="color: #25c6fe; margin-left:20px"></a>
      
    
  </p>
  <ul id="menu-new-1" class="menu">
    
      <li>
        <a href="/">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-fort-awesome faa-shake" aria-hidden="true"></i>
            首页
          </span>
        </a>
        
      </li>
    
      <li>
        <a href="/archives">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-archive faa-shake" aria-hidden="true"></i>
            归档
          </span>
        </a>
        
          <ul class="sub-menu">
            
              <li>
                <a href="/categories/算法/">
                  <i class="fa fa-code" aria-hidden="true"></i>
                  算法
                </a>
              </li>
            
              <li>
                <a href="/categories/生活/">
                  <i class="fa fa-file-text-o" aria-hidden="true"></i>
                  生活
                </a>
              </li>
            
              <li>
                <a href="/categories/笔记/">
                  <i class="fa fa-book" aria-hidden="true"></i>
                  笔记
                </a>
              </li>
            
              <li>
                <a href="/categories/资源/">
                  <i class="fa fa-cloud-download" aria-hidden="true"></i>
                  资源
                </a>
              </li>
            
          </ul>
        
      </li>
    
      <li>
        <a href="/music/">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-headphones" aria-hidden="true"></i>
            歌单
          </span>
        </a>
        
      </li>
    
      <li>
        <a href="/comment/">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-pencil-square-o faa-tada" aria-hidden="true"></i>
            留言板
          </span>
        </a>
        
      </li>
    
      <li>
        <a href="/links/">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-link faa-shake" aria-hidden="true"></i>
            友人帐
          </span>
        </a>
        
      </li>
    
      <li>
        <a href="/about/">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-meetup" aria-hidden="true"></i>
            关于
          </span>
        </a>
        
      </li>
    
      <li>
        <a href="/lab/">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-cogs" aria-hidden="true"></i>
            实验室
          </span>
        </a>
        
      </li>
    
      <li>
        <a href="/atom.xml">
          <span class="faa-parent animated-hover">
            <i class="fa  fa-rss faa-pulse" aria-hidden="true"></i>
            RSS
          </span>
        </a>
        
      </li>
    
  </ul>
  <p style="text-align: center; font-size: 13px; color: #b9b9b9;">&copy 2019 hexo-sakura</p>
</div>
<button onclick="topFunction()" class="mobile-cd-top" id="moblieGoTop" title="Go to top" style="display: none;"><i class="fa fa-chevron-up" aria-hidden="true"></i></button>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<!-- require MetingJS -->
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>
<style>
  .aplayer .aplayer-lrc {
    height: 35px;
  }
  .aplayer .aplayer-lrc p{
    font-size: 16px;
    font-weight: 700;
    line-height: 18px !important;
  }
  .aplayer .aplayer-lrc p.aplayer-lrc-current{
    color: #FF1493;
  }
  .aplayer.aplayer-narrow .aplayer-body{
    left: -66px !important;
  }
  .aplayer.aplayer-fixed .aplayer-lrc {
    display: none;
  }
  .aplayer .aplayer-lrc.aplayer-lrc-hide {
      display:none !important;
  }
  .aplayer.aplayer-fixed .lrc-show {
    display: block;
    background: rgba(255, 255, 255, 0.8);
  }
</style>
<meting-js

    id="2899869488"

    server="netease"

    type="playlist"

    fixed="true"

    autoplay="false"

    loop="all"

    order="random"

    preload="auto"

    volume="0.7"

    mutex="true"

</meting-js>
<script>
  $(function(){
    $('body').on('click', '.aplayer', function(){
      if($('.aplayer-button').hasClass('aplayer-play')) {
        $('.aplayer-lrc').removeClass('lrc-show');
      } else {
        $('.aplayer-lrc').addClass('lrc-show');
      }
    })
  });
</script><!-- hexo-inject:begin --><!-- Begin: Injected MathJax -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config("");
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
      all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });
</script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<!-- End: Injected MathJax -->
<!-- hexo-inject:end -->
</body>
</html>